import { ObjCreate } from "../common/ObjCreate";
import { JewelComboboxRenderer } from "./JewelComboboxRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { Language } from "../../../../extend/language/Language";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { EJewel } from "../../../../Message/Public/EJewel";
import { GComboBox } from "../../../../com/mui/controls/GComboBox";
type int = number;
//class JewelClassComboxs
    
    export  class JewelClassComboxs /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._levelCb = ObjCreate.createGComboBox(0, 0, 62, 20, null, this);
            this._levelCb.dropdown.setStyle("cellRenderer", JewelComboboxRenderer);
            this._levelCb.dataProvider = this.getJewelLevelDataProvider();
            this._levelCb.addEventListener(flash.events.Event.CHANGE, this.onSelectedChange);
            this._typeCb = ObjCreate.createGComboBox(this._levelCb.x + this._levelCb.width + 5, 0, 62, 20, null, this);
            this._typeCb.dropdown.setStyle("cellRenderer", JewelComboboxRenderer);
            this._typeCb.dataProvider = this.getJewelTypeDataProvider();
            this._typeCb.addEventListener(flash.events.Event.CHANGE, this.onSelectedChange);
            return;
        }

        /* internal  */onSelectedChange(arg1: Object /* flash.events.Event */): void
        {
            this.dispatchEvent(new Object /* flash.events.Event */(flash.events.Event.CHANGE, false, false));
            return;
        }

        public getJewelLevelDataProvider(): DataProvider
        {
            var loc2=null;
            var loc1=new DataProvider();
            loc1.addItem({"label": Language.getString(61059), "value":-1});
            var loc3=1;
            while (loc3 <= 10) 
            {
                loc2 = new Object();
                loc2.label = GameDefConfig.instance.getJewelLevel(loc3).name;
                loc2.value = loc3;
                loc1.addItem(loc2);
                ++loc3;
            }
            return loc1;
        }

        public getJewelTypeDataProvider(): DataProvider
        {
            var loc1=new DataProvider();
            loc1.addItem({"label": Language.getString(61060), "value":-1});
            loc1.addItem(this.getTypeItem(EJewel._EJewelHabitus));
            loc1.addItem(this.getTypeItem(EJewel._EJewelPower));
            loc1.addItem(this.getTypeItem(EJewel._EJewelAgile));
            loc1.addItem(this.getTypeItem(EJewel._EJewelSpiritual));
            loc1.addItem(this.getTypeItem(EJewel._EJewelBrains));
            loc1.addItem(this.getTypeItem(EJewel._EJewelLife));
            loc1.addItem(this.getTypeItem(EJewel._EJewelPhysicalAttack));
            loc1.addItem(this.getTypeItem(EJewel._EJewelMagicAttack));
            loc1.addItem(this.getTypeItem(EJewel._EJewelPhysicalCrit));
            loc1.addItem(this.getTypeItem(EJewel._EJewelMagicCrit));
            loc1.addItem(this.getTypeItem(EJewel._EJewelPhysicalDefense));
            loc1.addItem(this.getTypeItem(EJewel._EJewelMagicDefense));
            loc1.addItem(this.getTypeItem(EJewel._EJewelJouk));
            loc1.addItem(this.getTypeItem(EJewel._EJewelHit));
            loc1.addItem(this.getTypeItem(EJewel._EJewelToughness));
            loc1.addItem(this.getTypeItem(EJewel._EJewelPass));
            return loc1;
        }

        /* internal  */getTypeItem(arg1: int): Object
        {
            var loc1=new Object();
            loc1.label = GameDefConfig.instance.getEJewel(arg1).text1;
            loc1.value = arg1;
            return loc1;
        }

        public get jewelType(): int
        {
            if (this._typeCb.selectedItem) 
            {
                return this._typeCb.selectedItem["value"];
            }
            return -1;
        }

        public get jewelLevel(): int
        {
            if (this._levelCb.selectedItem) 
            {
                return this._levelCb.selectedItem["value"];
            }
            return -1;
        }

        /* internal */ /* var */_levelCb: GComboBox;

        /* internal */ /* var */_typeCb: GComboBox;
    }
